(function() {
    var getHome = function() {
        var home = null;
        var scripts = document.getElementsByTagName("script");
        var path = "/resource/webcat/analytics.js";

        for(var i = 0, length = scripts.length; i < length; i++) {
            var src = scripts[i].src;

            if(src != null && src != undefined && src.length > 0) {
                var k = src.indexOf(path);

                if(k > -1) {
                    home = src.substring(0, k);
                    break;
                }
            }
        }

        if(home == null) {
            home = "";
        }
        else {
            if(home.length >= 1) {
                if(home.substring(home.length - 1) == "/") {
                    home = home.substring(0, home.length - 1);
                }
            }
        }
        return home;
    };

    var url = document.location.href;
    var referer = document.referrer;
    var params = "url=" + encodeURIComponent(url) + "&ref=" + encodeURIComponent(referer) + "&r=" + (new Date().getTime());
    new Image().src = getHome() + "/analytics/log.html?" + params;
})();
